package com.sgb.capital.view.ui.adapter;

import android.view.View;

import com.sgb.capital.R;
import com.sgb.capital.model.ProcessLogBean;
import com.sgb.capital.utils.Utils;
import com.sgb.capital.view.widget.BaseRecyclerViewAdapterHelper.BaseQuickAdapter;
import com.sgb.capital.view.widget.BaseRecyclerViewAdapterHelper.viewholder.BaseViewHolder;

import java.util.List;

/**
 * 日志
 */
public class OrderLog2Adapter extends BaseQuickAdapter<ProcessLogBean, BaseViewHolder> {

    public OrderLog2Adapter(List<ProcessLogBean> beans) {
        super(R.layout.orderlog_2adapter, beans);
    }

    @Override
    protected void convert(BaseViewHolder helper, final ProcessLogBean item) {
        if (getData().size() == 0) {
            return;
        }
        helper
                .setText(R.id.tv_optType, item.optType == -1 ? "发起流程" : item.optType == 0 ? "已拒绝" : item.optType == 1 ? "已通过" : "审批中")
                .setText(R.id.tv_created, item.time)
                .setText(R.id.tv_content,  item.reason)
                .setText(R.id.tv_creatorName, item.optUserName)
                .setTextColor(R.id.tv_optType, Utils.getColor(item.optType == -1 ? R.color.color_B79255 : item.optType == 0 ? R.color.color_FF6600 :
                        item.optType == 1 ? R.color.color_78C06E : R.color.color_5792FD));
        helper.getView(R.id.view1).setVisibility(helper.getLayoutPosition() == 0 ? View.INVISIBLE : View.VISIBLE);
        helper.getView(R.id.view2).setVisibility(helper.getLayoutPosition() == getData().size() - 1 ? View.INVISIBLE : View.VISIBLE);
    }
}
